package main

import "fmt"

type ListNode struct {
	Val int
	Next *ListNode
}

func Con_twolist(l1 *ListNode,l2 *ListNode) *ListNode{
	if l1 == nil{
		return l2
	}else if l2 == nil {
		return l1
	}else if l1.Val <= l2.Val {
		l1.Next = Con_twolist(l1.Next,l2)
		return l1
	}else {
		l2.Next = Con_twolist(l1,l2.Next)
		return l2
	}

}

func main(){
	l1 := &ListNode{
		Val: 2,
		Next: &ListNode{
			Val: 5,
			Next: &ListNode{
				Val: 8,
				Next: &ListNode{
					Val:  10,
					Next: nil,
				},
			},
		},
	}

	l2 := &ListNode{
		Val: 3,
		Next: &ListNode{
			Val: 4,
			Next: &ListNode{
				Val:  6,
				Next: &ListNode{
					Val:  9,
					Next: nil,
				},
			},
		},
	}
	list := Con_twolist(l1,l2)
	for list != nil{
		fmt.Printf("%v\t",list.Val)
		list = list.Next
	}
}
